import {
	getProductById
} from "./api.js"
export default {
	onShow() {
		
	},
	onLoad: function(option) {
		this.productId = option.productId;
		if(this.productId !== null && this.productId !== undefined){
			this.onLoadCall();
		}else{
			uni.showToast({
				title: '数据错误，返回上一页！',
				icon: "fail",
				duration: 1000,
			});
			this.goBack();
		}
	},

	data() {
		return {
			productId: null, 
			product: null
		}
	},

	methods: {
		onLoadCall(){
			const params = {
				id: this.productId 
			}
			getProductById(params).then((res) =>{
				this.product = res.data
			}).catch((error) =>{})
		},
		// 返回上一级
		goBack() {
			uni.navigateBack({ delta: 1 })
		},
	}
}